package net.lgy.controller;


import lombok.extern.slf4j.Slf4j;
import net.lgy.service.StreamService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.http.MediaTypeFactory;
import org.springframework.stereotype.Controller;
import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestHeader;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import reactor.core.publisher.Flux;

@RestController
@Slf4j
@RequestMapping("/api/chat")
public class StreamController {
        @Autowired
        private StreamService streamService;



    @RequestMapping(value = "/stream",produces = MediaType.TEXT_EVENT_STREAM_VALUE)
    public Flux<String> chatStream(@RequestHeader("token_ai_pan") String token, @RequestBody String message){
        return streamService.handleChatStream(token,message);
    }


















    }



